import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'package:pass_log/app/core/theme/customize.dart';

class ThemeService extends GetxService {
  static ThemeService get to => Get.find<ThemeService>();

  // 暗黑模式判断标志
  final _isDarkMode = Get.isDarkMode.obs;
  bool get isDarkMode => _isDarkMode.value;

  // 暗黑主题、明亮主题、当前应用主题
  final _darkTheme = const MaterialTheme(TextTheme()).dark();
  final _lightTheme = const MaterialTheme(TextTheme()).light();
  ThemeData get currentTheme => _isDarkMode.value ? _darkTheme : _lightTheme;
  ColorScheme get curColorScheme => _isDarkMode.value ? _darkTheme.colorScheme : _lightTheme.colorScheme;

  // 切换主题模式
  void switchThemeMode() {
    _isDarkMode.value = !_isDarkMode.value;
    Get.changeTheme(currentTheme);
  }
}
